package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.AssesRuleArtificial;
import com.ruoyi.system.mapper.AssesRuleArtificialMapper;
import com.ruoyi.system.service.IAssesRuleArtificialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.IntStream;

/**
 * 人工考核规则Service业务层处理
 *
 * @author ruoyi
 * @date 2024-04-22
 */
@Service
public class AssesRuleArtificialServiceImpl implements IAssesRuleArtificialService
{
    @Autowired
    private AssesRuleArtificialMapper assesRuleArtificialMapper;

    /**
     * 查询人工考核规则
     *
     * @param id 人工考核规则主键
     * @return 人工考核规则
     */
    @Override
    public AssesRuleArtificial selectAssesRuleArtificialById(Long id)
    {
        return assesRuleArtificialMapper.selectAssesRuleArtificialById(id);
    }

    /**
     * 查询人工考核规则列表
     *
     * @param assesRuleArtificial 人工考核规则
     * @return 人工考核规则
     */
    @Override
    public List<AssesRuleArtificial> selectAssesRuleArtificialList(AssesRuleArtificial assesRuleArtificial)
    {
        List<AssesRuleArtificial> assesRuleArtificials = assesRuleArtificialMapper.selectAssesRuleArtificialList(assesRuleArtificial);
        IntStream.range(0,assesRuleArtificials.size()).forEach(
                i->{
                    int index = i+1;
                    AssesRuleArtificial assesRuleArtificialVo = assesRuleArtificials.get(i);
                    assesRuleArtificialVo.setOrderNum(index);
                });
        return assesRuleArtificials;
    }

    /**
     * 新增人工考核规则
     *
     * @param assesRuleArtificial 人工考核规则
     * @return 结果
     */
    @Override
    public int insertAssesRuleArtificial(AssesRuleArtificial assesRuleArtificial)
    {
        return assesRuleArtificialMapper.insertAssesRuleArtificial(assesRuleArtificial);
    }

    /**
     * 修改人工考核规则
     *
     * @param assesRuleArtificial 人工考核规则
     * @return 结果
     */
    @Override
    public int updateAssesRuleArtificial(AssesRuleArtificial assesRuleArtificial)
    {
        return assesRuleArtificialMapper.updateAssesRuleArtificial(assesRuleArtificial);
    }

    /**
     * 删除人工考核规则信息
     *
     * @param id 人工考核规则主键
     * @return 结果
     */
    @Override
    public int deleteAssesRuleArtificialById(Long id)
    {
        return assesRuleArtificialMapper.deleteAssesRuleArtificialById(id);
    }
}
